package com.kyub.spring.gears.model;

import java.util.HashMap;
import java.util.Map;

/**
 * Layout for attachmets
 */
public class FileLayout implements FieldLayout {

    String refPropertyName;

    String persistPath;

    String mimeType;

    public static final Map<String, String> knownMimeType = new HashMap<String, String>();

    static {
        knownMimeType.put("application/pdf", "pdf");    //TODO ADD mime/types
    }

    public String getExtension() {
        if (mimeType != null && knownMimeType.get(mimeType) != null) {
            return knownMimeType.get(mimeType);
        } else {
            return "dat";
        }
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public String getRefPropertyName() {
        return refPropertyName;
    }

    public void setRefPropertyName(String refPropertyName) {
        this.refPropertyName = refPropertyName;
    }

    public String getPersistPath() {
        return persistPath;
    }

    public void setPersistPath(String persistPath) {
        this.persistPath = persistPath;
    }

    public boolean isProxyNeeded() {
        return persistPath != null;
    }
}
